package net.qiqbframework.messaging.monitoring;


import net.qiqbframework.messaging.Message;

import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

public interface MessageMonitor<T extends Message<?>> {


    MonitorCallback onMessageIngested(@Nonnull T message);


    default Map<? super T, MonitorCallback> onMessagesIngested(@Nonnull Collection<? extends T> messages) {
        return messages.stream().collect(Collectors.toMap(msg -> msg, this::onMessageIngested));
    }


}
